using System;
using Spread.Common.Features.Sample;
using FarPoint.Win.Spread.Model;
using Spread.Common.DataStore;

namespace Spread.Sorting
{
    public partial class Introduction : BaseSampleControl
    {
        public Introduction()
        {
            InitializeComponent();
            fpSpread1_Sheet1.DataAutoSizeColumns = false;
            fpSpread1_Sheet1.SetColumnWidth(-1, 120);
            fpSpread1_Sheet1.SetRowHeight(-1, 21);

            var dataSource = new DataService().JsonDataSource.GetMovieRecords();
            fpSpread1_Sheet1.DataSource = dataSource;

            fpSpread1_Sheet1.SetColumnAllowAutoSort(-1, true);
        }

        private void _bSortAToZ_Click(object sender, EventArgs e)
        {
            CellRange cr = fpSpread1_Sheet1.GetSelection(0);
            if (cr != null)
                fpSpread1_Sheet1.SortRange(cr.Row, cr.Column, cr.RowCount, cr.ColumnCount, true, new FarPoint.Win.Spread.SortInfo[] { new FarPoint.Win.Spread.SortInfo(cr.Column, true) });
        }

        private void _bSortZToA_Click(object sender, EventArgs e)
        {
            CellRange cr = fpSpread1_Sheet1.GetSelection(0);
            if (cr != null)
                fpSpread1_Sheet1.SortRange(cr.Row, cr.Column, cr.RowCount, cr.ColumnCount, true, new FarPoint.Win.Spread.SortInfo[] { new FarPoint.Win.Spread.SortInfo(cr.Column, false) });
        }
    }
}


//
//Introduction.Designer.cs
//


namespace Spread.Sorting
{
    partial class Introduction
    {
        /// <summary> 
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary> 
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Component Designer generated code

        /// <summary> 
        /// Required method for Designer support - do not modify 
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.fpSpread1 = new FarPoint.Win.Spread.FpSpread();
            this.fpSpread1_Sheet1 = new FarPoint.Win.Spread.SheetView();
            this._bSortAToZ = new System.Windows.Forms.Button();
            this._bSortZToA = new System.Windows.Forms.Button();
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.pnlMain.SuspendLayout();
            this.pnlControls.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.fpSpread1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.fpSpread1_Sheet1)).BeginInit();
            this.groupBox1.SuspendLayout();
            this.SuspendLayout();
            // 
            // pnlMain
            // 
            this.pnlMain.Controls.Add(this.fpSpread1);
            // 
            // pnlControls
            // 
            this.pnlControls.Controls.Add(this.groupBox1);
            // 
            // fpSpread1
            // 
            this.fpSpread1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.fpSpread1.Location = new System.Drawing.Point(0, 0);
            this.fpSpread1.Name = "fpSpread1";
            this.fpSpread1.Sheets.AddRange(new FarPoint.Win.Spread.SheetView[] {
            this.fpSpread1_Sheet1});
            this.fpSpread1.Size = new System.Drawing.Size(477, 487);
            this.fpSpread1.TabIndex = 0;
            // 
            // fpSpread1_Sheet1
            // 
            this.fpSpread1_Sheet1.Reset();
            this.fpSpread1_Sheet1.SheetName = "Sheet1";
            // Formulas and custom names must be loaded with R1C1 reference style
            this.fpSpread1_Sheet1.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.R1C1;
            this.fpSpread1_Sheet1.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.A1;
            // 
            // _bSortAToZ
            // 
            this._bSortAToZ.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this._bSortAToZ.Location = new System.Drawing.Point(13, 19);
            this._bSortAToZ.Name = "_bSortAToZ";
            this._bSortAToZ.Size = new System.Drawing.Size(115, 23);
            this._bSortAToZ.TabIndex = 0;
            this._bSortAToZ.Text = "Sort A -> Z";
            this._bSortAToZ.UseVisualStyleBackColor = true;
            this._bSortAToZ.Click += new System.EventHandler(this._bSortAToZ_Click);
            // 
            // _bSortZToA
            // 
            this._bSortZToA.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this._bSortZToA.Location = new System.Drawing.Point(13, 59);
            this._bSortZToA.Name = "_bSortZToA";
            this._bSortZToA.Size = new System.Drawing.Size(115, 23);
            this._bSortZToA.TabIndex = 1;
            this._bSortZToA.Text = "Sort Z -> A";
            this._bSortZToA.UseVisualStyleBackColor = true;
            this._bSortZToA.Click += new System.EventHandler(this._bSortZToA_Click);
            // 
            // groupBox1
            // 
            this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.groupBox1.Controls.Add(this._bSortAToZ);
            this.groupBox1.Controls.Add(this._bSortZToA);
            this.groupBox1.Location = new System.Drawing.Point(6, 14);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(148, 88);
            this.groupBox1.TabIndex = 2;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "Selected Range Sorting";
            // 
            // Introduction
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.Name = "Introduction";
            this.pnlMain.ResumeLayout(false);
            this.pnlControls.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.fpSpread1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.fpSpread1_Sheet1)).EndInit();
            this.groupBox1.ResumeLayout(false);
            this.ResumeLayout(false);

        }

        #endregion

        private FarPoint.Win.Spread.FpSpread fpSpread1;
        private FarPoint.Win.Spread.SheetView fpSpread1_Sheet1;
        private System.Windows.Forms.Button _bSortZToA;
        private System.Windows.Forms.Button _bSortAToZ;
        private System.Windows.Forms.GroupBox groupBox1;
    }
}
